    <div id="oneNoteList">
        <!--数据列表-->
        <table class="layui-table"  lay-filter="editList" id="editList" style="text-align: center;"></table>
    </div>
    <script type="text/html" id="headerToolsBar">
        <!--功能按钮-->
        <div class="layui-btn-container" style="margin: 10px;">
            <a class="layui-btn layui-btn-sm" data-method="offset" data-type="auto" lay-event="add">
                <i class="layui-icon layui-icon-add-1"></i>
                <span>添加</span>
            </a>
            <a class="layui-btn layui-btn-sm" data-method="offset" data-type="auto" lay-event="sort">
                <i class="layui-icon layui-icon-list"></i>
                <span>保存排序</span>
            </a>
            <a class="layui-btn layui-btn-sm" data-method="offset" data-type="auto" lay-event="init">
                <i class="layui-icon layui-icon-refresh"></i>
                <span>初始化按钮</span>
            </a>
            <a class="layui-btn layui-btn-danger layui-btn-sm" data-method="offset" data-type="auto" lay-event="delAll">
                <i class="layui-icon layui-icon-delete"></i>
                <span>删除所有</span>
            </a>
            <a class="layui-btn layui-btn-sm" data-method="offset" data-type="auto" lay-event="reture">
                <i class="layui-icon layui-icon-return"></i>
                <span>返回</span>
            </a>
            <a class="layui-btn layui-btn-sm" data-method="offset" data-type="auto" lay-event="reload">
                <i class="layui-icon layui-icon-refresh-3"></i>
                <span>刷新</span>
            </a>
        </div>
    </script>
    <script type="text/html" id="sortBar">
        <!--排序-->
        <a alt='上移' href='javascript:;' class='link moveup '    lay-event="upTr" style="width: 20px;height: 20px;"><i class="iconfont iconlong-arrow-up"></i></a>
        <a alt='下移' href='javascript:;' class='link movedown '  lay-event="downTr" ><i class="iconfont iconlong-arrow-down"></i></a>
    </script>
    <script type="text/html" id="managerBar">
        <!--管理-->
        <a class="layui-btn layui-btn-xs "                   lay-event="edit"  >编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs "  lay-event="del"   >删除</a>
    </script>


    <script>
        layui.use(['setter','table','form'], function(){
            var setter = layui.setter;
            var table = layui.table;
            var $ = layui.$;
            var form = layui.form;
            var element = layui.element;
            var isStartForm = '${isStartForm}';
            //弹出提示框
            // var isReturn = '${isReturn}';
            // if(isReturn=='true'){ layer.msg("操作成功！",{time:500,icon:6})}
            // else if(isReturn=='false'){ layer.msg("操作失败！",{time:500,icon:5})}

            //全局使用(btn-class)。即所有弹出层都默认采用，但是单个配置skin的优先级更高
            layer.config({
                skin: 'btn-class'
            })

            table.render({
                elem: '#editList' //指定原始表格元素选择器（推荐id选择器）
                ,title:"操作按钮节点信息"
                // ,height: 315 //容器高度
                ,toolbar: '#headerToolsBar'
                ,method:"post"
                ,url:serverPath.workflowPath+setter.workflowLinkPath+"bpmNodeButton/getByNode?modelId=${modelId}&nodeId=${nodeId}"
                ,cols: [[
                    {field: 'id', title: '按钮名',hide:true}
                    ,
                    {type:'numbers', title: '序号', align: 'center', width: 80}
                    , {field: 'btnname', title: '按钮名', minWidth: 150, align: 'center'}
                    , {
                        field: 'operatortype', title: '操作类型', align: 'center', templet: function (d) {
                            if (isStartForm == 1) {
                                // 起始节点的操作类型转换文字叙述
                                switch (d.operatortype) {
                                    case 1:
                                        return "启动流程";
                                    case 2:
                                        return "流程图";
                                    case 3:
                                        return "打印";
                                    case 6:
                                        return "保存表单";
                                    case 14:
                                        return "Web签章";
                                    case 15:
                                        return "手写签章";
                                    default:
                                        return "无";
                                }
                            } else {
                                //其他节点的操作类型转换文字叙述
                                switch (d.operatortype) {
                                    case 1:
                                        return "同意";
                                    case 2:
                                        return "反对";
                                    case 3:
                                        return "弃权";
                                    case 4:
                                        return "驳回";
                                    case 5:
                                        return "驳回到发起人";
                                    case 6:
                                        return "转交代办";
                                    case 7:
                                        return "补签";
                                    case 8:
                                        return "保存表单";
                                    case 9:
                                        return "流程图";
                                    case 10:
                                        return "打印";
                                    case 11:
                                        return "审批历史";
                                    case 12:
                                        return "自由回退";
                                    case 14:
                                        return "Web签章";
                                    case 15:
                                        return "手写签章";
                                    case 16:
                                        return "沟通意见";
                                    case 17:
                                        return "加签";
                                    case 43:
                                        return "撤销";
                                    default:
                                        return "无";
                                }
                            }
                        }
                    }
                    , { title: '排序', toolbar: '#sortBar', width: 150, align: 'center'}
                    , { title: '管理', toolbar: '#managerBar', width: 150, align: 'center'}

                ]]
            });

            //刷新页面数据
            function reload(){
                table.reload('editList', {});
            }

            //行工具监听单击事件
            table.on('tool(editList)', function(obj){
                //判断是升还是降，upTrue为升，downTr为降
                switch (obj.event) {
                    case 'edit':
                        addOrEdit(obj.data.id);
                        break;
                    case 'del':
                        delNodeBtn(obj.data.id);
                        break;
                    case 'upTr':
                        upTr(obj.tr);
                        break;
                    case 'downTr':
                        downTr(obj.tr);
                        break;
                }
            });

            //功能按钮区  头工具监听事件
            table.on('toolbar(editList)', function (obj) {
                // var checkStatus = table.checkStatus(obj.config.id);
                switch (obj.event) {
                    case 'add':
                        addOrEdit();
                        break;
                    case 'sort':
                        sort();
                        break;
                    case 'init':
                        initOne('${modelId}', '${nodeId}');
                        break;
                    case 'delAll':
                        delAll('${modelId}', '${nodeId}');
                        break;
                    case 'reture':
                        reture();
                        break;
                    case 'reload':
                        reload();
                        break;
                };
            });

            //上移
            function upTr(thisTr) {
                var prevTr = $(thisTr).prev();
                if(prevTr){
                    thisTr.insertBefore(prevTr);
                }
            }
            //下移
            function downTr(thisTr) {
                var nextTr = $(thisTr).next();
                if(nextTr){
                    thisTr.insertAfter(nextTr);
                }
            }
            //编辑 弹窗
            function addOrEdit(itemId) {
                // 是否刷新
                window.isNeedReload=true;
                var editUrlStr;
                if(itemId){ editUrlStr = ('&&id=' + itemId) }
                layer.open({
                    type: 2,
                    title: "编辑流程按钮",
                    shade: 0.3,
                    left: 200,
                    area: ['916px', '520px'],
                    content: serverPath.workflowPath + setter.workflowLinkPath + 'bpmNodeButton/view/edit?modelId=${modelId}&&nodeId=${nodeId}&&buttonFlag=${buttonFlag}'+editUrlStr
                   ,end:function (layero,index) {
                        //刷新表格
                        if(isNeedReload){
                            reload();
                            return false;
                        }
                    }
                });
            };

            //删除 接口
            function delNodeBtn(itemId) {
                layer.confirm('确认删除吗？', {
                    btn: ['是', '否']
                    , title: '提示信息'
                    , yes: function () {
                        gotoUrl('/del?modelId=${modelId}&&nodeId=${nodeId}&&buttonFlag=${buttonFlag}&&id=' + itemId);
                        layer.close(layer.index);
                    }
                });

            };

            //保存排序按钮，获取最新排序
            function sort() {
                var aryId = [];
                $(".layui-table-main .layui-table tr .layui-hide").children().each(function () {
                    aryId.push($(this).text());
                });
                if (aryId.length == 0) {
                    layer.msg('没有定义按钮!', {icon: 0});//提示信息修改
                    return;
                } else {
                    saveSort(aryId.toString());
                }
            };
            //保存排序，执行操作
            function saveSort(aryIdStr) {
                $.ajax({
                    url: "${ctx}/workflow/bpmNodeButton/view/sort"
                    , data:{ ids: aryIdStr }
                    , type: "get"
                    , contentType: 'application/text'
                    , dataType: 'text'
                    , success: function (result) {
                        //刷新页面
                        reload();
                        console.log(result)
                        layer.msg('保存成功!', {icon: 6});
                    }
                });
            }
            //初始化
            function initOne(modelId, nodeId) {
                layer.confirm('确认初始化该流程节点的按钮吗？', {
                    icon: 3
                    , title: '提示'
                }, function () {
                    if (nodeId == null) {
                        gotoUrl("/init?modelId=" + modelId + "&&isEdit=edit");
                    } else {
                        gotoUrl("/init?modelId=" + modelId + "&&nodeId=" + nodeId + "&&isEdit=edit");
                    }
                    layer.close(layer.index);
                })
            }
            //删除所有
            function delAll(modelId, nodeId) {
                layer.confirm('确认删除该流程节点的按钮吗？', {
                    icon: 3
                    , title: '提示'
                }, function () {
                    if (nodeId == null) {
                        gotoUrl("/deByDefNodeId?modelId=" + modelId + "&&isEdit=edit");
                    } else {
                        gotoUrl("/deByDefNodeId?modelId=" + modelId + "&&nodeId=" + nodeId + "&&isEdit=edit");
                    }
                    layer.close(layer.index);
                })
            }
            //返回
            function reture() {
                gotoUrl("/list?modelId=${RequestParameters.modelId!}");
            };

        });

        //按钮接口跳转
        function gotoUrl(url){
            changeLoad("${ctx}/workflow/bpmNodeButton/view"+url);
        }
    </script>
